public class Test {
    public int takeAttendance(int[] records) {
        int left =0;
        int right = records.length-1;
        while(left < right ) {
            int   mid = left +(right - left ) /2;
            if(records[mid] == mid ) {
                left = mid+1;
            }else{
                right = mid;
            }

        }
        if(records[left] ==  left ) {
            return left + 1;
        }
        return left;

    }
    public int takeAttendance2(int[] records) {
        int n= records.length;
        int[] hash = new int[n+1];
        for(int i = 0 ; i < n ; i++){
            int x = records[i];
            hash[x] ++;
        }
        for(int i =0 ;i <hash.length ; i++){
            if(hash[i] == 0){
                return i;
            }
        }
        return 0;

    }
    public int takeAttendance3(int[] records) {
        int n = records.length + 1;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += i;
        }
        for (int i = 0; i < records.length; i++) {
            sum -= records[i];
        }
        return sum;

    }
    public int takeAttendance4(int[] records) {
        int n = records.length+1;
        int sum =0;
        for(int i =0;i< n; i++){
            sum ^= i;

        }
        for(int i = 0;i<records.length;i++){
            sum ^= records[i];
        }
        return sum;
    }
    public int takeAttendance5(int[] records) {
        for(int i =0 ;i <records.length;i++){
            if(records[i] != i){
                return i;
            }
        }
        return records.length;


    }
}
